﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;


namespace HighFantasyRPG
{

    public class MessageBox
    {
        private Texture2D texture;
        public int id, time, delay, counter;
        private ContentManager Content;
        public string text;
        public Rectangle area;
        public Vector2 pos;
        public SpriteFont font;
        public bool isVisible;
        

        public MessageBox(ContentManager content, int counter, int delay)
            {
                this.Content = content;
                this.delay = delay * 4000;
                this.counter = counter;
                this.time = 0;
                this.font = content.Load<SpriteFont>("Fonts/Panel");
                this.texture = content.Load<Texture2D>("Background/MessageBox");
                pos = new Vector2(100, 400);
            }

        public void Update(GameTime gameTime)
        {
            if (isVisible == true)
                {
            int tick = counter;
            if (time <= delay)
            {

                for (int i = 1; i <= 50; i++)
                {
                    time++;

                    if (time == delay)
                        counter += 1;
                }
                if (counter == delay / 1000)
                {
                    time = 0;
                    tick = 0;
                    counter = tick;
                    isVisible = false;
                }

            }
            else
                time = 0;

                }
            
        }

        public void Draw(SpriteBatch spriteBatch, float CameraPosX)
            {

                spriteBatch.Draw(texture, new Vector2(pos.X + CameraPosX, pos.Y), Color.White);
                spriteBatch.DrawString(font, text, new Vector2(pos.X + CameraPosX + 10, pos.Y), Color.White);
            }
    }
}
